home *** CD-ROM | disk | FTP | other *** search
- Path: news.cc.emory.edu!larry!libjrm
- From: John Marsh <libjrm@emory.edu>
- Newsgroups: comp.lang.c
- Subject: HELP! #include <math.c> question
- Date: Sat, 20 Jan 1996 14:01:06 -0500
- Organization: Emory University
- Message-ID: <Pine.SV4.3.91.960120135347.12016A-100000@larry>
- NNTP-Posting-Host: larry.cc.emory.edu
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
- X-Sender: libjrm@larry
-
- Hi folks-
-
- I'm trying to learn C, and have encountered a problem compiling a
- bit of code. I've tried it on two GNU compilers at different locations,
- and gotten the same error message. My code looks like this:
- _________________________________________________________________________
-
- #include <stdio.h>
- #include <math.h>
-
- int
- main(void)
- {
- double first, second,
- first_sqrt,
- second_sqrt,
- sum_sqrt;
-
- printf("Enter the first number> ");
- scanf("%lf",&first);
- first_sqrt = sqrt(first);
- printf("The square root of the first number is %.2f\n", first_sqrt);
-
- printf("Enter the second number> ");
- scanf("%lf",&second);
- second_sqrt = sqrt(second);
- printf("The square root of the second number is %.2f\n", second_sqrt);
-
- sum_sqrt = sqrt(first + second);
- printf("The square root of the sum of the two numbers is %.2f\n",
- sum_sqrt);
-
- return(0);
- }
- _____________________________________________________________________________
-
- When I try to compile it, I get an "Undefined symbol (sqrt) - Symbol
- referencing error" message. Shouldn't <math.h> recognize sqrt? I must be
- missing something, obviously, but I'm at a loss... Any help would be
- greatly appreciated (and if you choose to respond, please .cc me at
- libjrm@emory.edu if you don't mind).
-
- Many thanks in advance!
-
- John Marsh
- Reference Dept. - Woodruff Library
- Emory University - Atlanta, GA
- (404) 727-6876
- libjrm@emory.edu
-
-
-